/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2020年2月1日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.practice;

import java.util.Arrays;

/**
 * @Type A20200201_insertsort
 * @Desc
 * @author 52489
 * @date 2020年2月1日
 * @Version V1.0
 */
public class A20200201_insertsort {
    public static void main(String[] args) {
        int arr[] = { 1, 3, 2, 7, 5, 4 };
        insertSort(arr);
        System.out.println(Arrays.toString(arr));
    }

    /**
     * @param nums
     */
    private static void insertSort(int[] nums) {
        for (int i = 1; i < nums.length; i++) {
            int tmp = nums[i];
            int k = i - 1;
            while (k >= 0 && nums[k] > tmp) {
                nums[k + 1] = nums[k];
                k--;
            }
            nums[k + 1] = tmp;
        }
    }
}
